<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1.

  
function fn(a){


      // 对前10个元素进行升序排序
     var b= a.slice(0, a.length/2).sort(function (a, b) {
        return a - b;
      });

      // 对后10个元素进行降序排序
    var c=  a.slice(a.length/2).sort(function (a, b) {
        return b - a;
      });
    //   将b和c连接起来
      for(var i=0;i<c.length;i++){
        b.push(c[i])

      }
      return b;
    }
      console.log(fn([
        "2",
        "5",
        "6",
        "10",
        "4",
        "18",
        "75",
        "96",
        "66",
        "52",
        "44",
        "13",
        "15",
        "62",
        "25",
        "33",
        "36",
        "18",
        "2",
        "55",
        "88","15","46"
      ]));
    // 2.
    // 随机生产20个元素的数组
    // Math.ceil()向上取整数     Math.floor()向下取整数
    // Math.random()随机数(90,1]
function fn1(n){
  var arr=[];
    for(var i=0;i<n;i++){
      var num=Math.ceil(Math.random()*100)//[0,100]随机数
      arr.push(num)
    }
    // 对前10个元素进行升序排序, 对后10个元素进行降序排序
    var ban =arr.length/2;
    var qian=arr.slice(0,ban)
    var hou=arr.slice(ban);
    qian=qian.sort(function(a,b){
      return a-b;
    })
    hou =hou.sort(function(a,b){
      return b-a
    })
    var o =qian.concat(hou);
    return o;
}
   
    console.log(fn1(80))



    </script>
  </body>
</html>
